﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Plugins.Qiniu;
using Qiniu.Storage;

namespace DotNetCoreApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class QiniuController : BaseController
    {
        public QiniuHelper qiniuHelper { get; set; }

        /// <summary>
        /// 获取Token
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ProducesResponseType(typeof(ReturnJson<string>),200)]
        public string GetToken()
        {
            return qiniuHelper.GetToken();
        }
        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ProducesResponseType(typeof(ReturnJson<ListResult>),200)]
        public ListResult GetList(string prefix, int count)
        {
            return qiniuHelper.GetList(prefix,count);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ProducesResponseType(typeof(ReturnJson), 200)]
        public async Task<bool> Delete(string path)
        {
            return qiniuHelper.Delete(path);
        }
    }
}
